package com.free.wang.demo02.controller;

import com.free.wang.demo02.entity.Student;
import com.free.wang.demo02.service.StudentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author admin
 * @Description 学生接口层
 * @date 2020-07-05 15:19:00
 */
@Slf4j
@RestController
@RequestMapping(value = "/api/student")
public class StudentController {

    @Autowired
    private StudentService studentService;

    @PostMapping(value = "/create")
    public String create(@RequestBody Student student) {
        this.studentService.insertSelective(student);
        return "SUCCESS";
    }

    @GetMapping(value = "/delete/{id}")
    public String delete(@PathVariable String id) {
        this.studentService.deleteByPrimaryKey(id);
        return "SUCCESS";
    }

    @PostMapping(value = "/update")
    public String update(@RequestBody Student student) {
        this.studentService.updateByPrimaryKeySelective(student);
        return "SUCCESS";
    }

    @GetMapping(value = "/page/{id}")
    public String page(@PathVariable String id) {
        this.studentService.selectByPrimaryKey(id);
        return "SUCCESS";
    }

}
